-
Notifications
You must be signed in to change notification settings - Fork 7
wip: rewrite #55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
wip: rewrite #55
Conversation
lib/default.nix
Outdated
|
|
||
| inherit (_callLib ./maintainers.nix) maintainers; | ||
| attrset = delib._callLib ./attrset.nix; | ||
| inherit (delib.attrset) getAttrByStrPath setAttrByStrPath hasAttrs; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe these functions should be kept under a separate "namespace"? like delib.attrs.getStr, delib.attrs.setStr and delib.attrs.has.
with this approach functions which should be first priority to the user (options) are in the global namespace, and other optional, but useful, are located under some kind of a namespace.
and repeated attr with the long function name just bothers me, to be honest. if the module is already named attrset, it would be pretty strange if functions don't work on attributes, but on something else
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, an interesting pattern, but the functions will still be called delib.attrs.setByStrPath, delib.attrs.getByStrPath, and delib.attrs.hasKeys.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this possible to compile all available modules (or for selected module systems) at once? otherwise, as can be seen in the example, it needs to be called for each moduleSystem, and not that performance is very critical, but going through all the files recursively several times for the same task feels wrong. and that's considering that the approach of denix is to include all systems in one file - why not compile them at once? the only issue is how to implement it, though...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea! I think compileModules would be a suitable name.
|
one more thing. while i was testing #59, i noticed that denix defines all options system-wide. example: i have a nixos and a home-manager vanilla modules. to make home-manager module independent from the user, i don't specify the full path to the option like to make this work, it's required to import the module with all home-manager modules like this approach allows for a multi-user configuration. if you define custom options in these modules, they always have a separate scope: i found about this trait of the library while i was migrating my git and gpg home-manager modules: while defined as delib modules, my other home-manager vanilla modules were unable to find my options to check for the enabled git, for example. this happened because my modules were dependent on themselves and not the options of home-manager. for example, to see is git enabled or not, i checked and because these as multi-user configurations were already considered before (#37), i think a rewrite is a good time to think about:
let's be real: almost everyone uses a single user on their desktops. root user doesn't count. and for a "personal working machine" environment i really like that denix defines options for all "platforms" in one place. for your desktop, you probably don't care about security and option scopes, but some modules are pretty inconvenient to enable on different "platforms": stylix is system-wide for the enable, but targets are located in home-manager; niri from the niri-flake is enabled on nixos level, but all options are user-wide. it feels good to define them from a single file and not import from different levels in the hierarchy, because these options should work together. it applies to the right now it's not a problem, because so, this user imports the nixos module. and then, to configure options from the module, the user is just obliged to use the "nixos scope" (global scope) - the user cannot configure anything from home-manager modules, because the options are located at the top level. in a way, that makes sense: you imported a nixos module - use it from the nixos scope. but still, why cannot you change the parameters that only change the home-manager config from the home-manager scope? the thing is i don't actually know is this good or not. i already shot myself in the foot a couple of times while trying to divide my configuration into fully separate home-manager and nixos modules, because some things should be done for the user on the system level: stylix wallpaper, xkb layout, autologin and more. maybe something like |
Should be. Actually, I didn't completely understand the text, but here's what I can say since it's relevant: The old solution creates all options in the user's root module system only under In the new solution, the "myconfig" system is currently implemented (I haven't pushed everything due to drawbacks) not in system configurations (NixOS, Home Manager, etc.), but in the Denix module system. This has the following pros and cons: Cons:
Pros:
Facts:
At the moment, this is the main problem in the rewrite, and I currently have no solution for it. |
|
oh. that's pretty hard to grasp. can i verify some things? if i understood it correctly, then the new denix module system will control itself from the denix module system itself? so, for example, if you have a gpg configuration for git which you only want to import if gpg module is enabled, you are required to check denix's gpg module's if the modules are planned to be exportable, then how the options for them would be presented? for example, right now i have the following in the home-manager module of my user: { inputs, ... }:
{
imports = [
inputs.self.homeModules.shimeoki
# ...
];
shimeoki = {
enable = true;
nh.flake = "/home/d/nixconfig";
waybar = {
keyboard-state.enable = false;
cava.enable = false;
mpd.enable = false;
};
# ...
};
# ...
}the user imports my module and configures it. very simple. how "denix module options" would be translated to this format, if they are dependent on themselves? via providing then, if i import a compiled nixos module from denix, does it import a home-manager module as well? if so, then how options for the home-manager denix configuration can be changed at the user level? |
yes
by custom function denix/examples/module/flake.nix Lines 30 to 36 in 3673512
delib.compileModule can create a module that you wrote, it does not add any pre-built home-manager modules to your configuration. The only two solutions that I was able to come up with:
|
oh. my wording is pretty bad. i meant the following: if i compile a nixos denix module, does it contain a home module as well? so, are platforms (nixos, darwin, home) fully separated or not? i actually just cannot get this from the code. i am not at that level of functional programming wizardry right now.
so, it's like 1 is the new approach for now, and 2 is the current (master branch) approach? if i got your point, the main concern is conditional imports. i think, there are three main use cases to use conditional imports:
personally, i think points 3 and 2 are not a problem:
i even think that usually you want to have the opposite of the second point - just read all the available options. otherwise, if you want to have a "safe" module system, then you need to check for every option availability and give a default value if the check failed. but the first point... i just recently started using nixos, and my build times are already a minute in average if nothing is being "really built" - only the parse and evaluation time. "you want to change a single option right now? - please, wait a minute.". it's terrifying for me to imagine build times for bigger systems. i think that's the main benefit. but for the performance, i think not compiling the unneeded modules for whole platforms or unused hosts/users is good enough. and there should be no problems with conditional imports here, because these options can be defined at the denix level before the compile process. if an another point is "avoiding accidental infinite recursions", then i don't think that should be considered. if the user made a mistake in defining the module, it's their fault. if that's possible, denix should just check so i am voting for the second approach. with this, denix is closer to the vanilla modules and the current implementation, while giving a bit more freedom to the user. |
it will not contain a home manager module. fully separated.
yes, but not completely. I don't push all the changes.
no, this is just an example of what could become possible, maybe not the best one. the main concern in the first solution is a lower chance of "accidental" infinite recursion errors, which occur when you do something extraordinary, though it's not guaranteed that this will happen. This is more of a master branch problem that shouldn't be repeated.
these two solutions are almost the same in terms of performance. your
unfortunately, it doesn't work that way. well, in the second solution, the user provides not the module itself, but the I think I can give brief descriptions for each solution:
Well, I think the second solution would be preferable. |
then, if the second approach is chosen, aren't multi-user configurations supported OOTB?
oh. thanks for the insight. i guess i underestimated nix.
well, pretty sad. also, i have one more point towards the second solution. option search engines like nuschtos search. a search should be pretty useful in complex configurations. maybe not so useful in a personal configuration, but if the modules are planned to be exportable (so "sharing modules" concept exists in the library), i think the support for this kind of tooling is great. though i haven't succeeded in deploying this tool in my configuration, it should just take a module and display all options automatically. there are probably more instruments like this, and i think they expect "vanilla" options to be available. so, the second solution should work OOTB once again. but if the first solution is chosen and support for these kind of search engines is desired, then either:
i don't think this is worth it. and there are probably more tools which expect plain vanilla options to be available. |
Yes, but making users manually call |
tasks
delib.module,delib.host,delib.ricewrappersproblems